<button class="layui-btn join" style="float: right;">加入专题</button>
<br><br>

<table id="demo" lay-filter="test" lay-data="{id: 'idTest'}"></table>
<script src="<?=SITE_BASE_URL?>/assets/js/jquery.min.js"></script>
<script src="<?=SITE_BASE_URL?>/assets/plugins/layui/layui.all.js"></script>
<link rel="stylesheet" href="<?=SITE_BASE_URL?>/assets/plugins/layui/css/layui.css"  media="all">
<script>
    //加入专题
    $(".join").click(function(){
        var arr=[]
        $.each($('input:checkbox:checked'),function(i,n){
            arr.push($(this).val())
        });
        $.ajax({
            type: "post",
            data: {arr:arr},
            dataType: "json",
            url: "<?=base_url("word/words/save_edit_table")?>",
            success: function (res) {
                if(res.code==0){
                    layer.msg(res.msg, {time: 1000},function(){
                        layui.use('table', function() {
                            var table = layui.table;
                            //重新加载表格
                            table.reload('demo', {
                                page: {
                                    curr: 1 //重新从第 1 页开始
                                }
                            });
                        })
                    });
                }else{
                    layer.msg(res.msg, {time: 2000});
                }
            }
        })
    })

    //动态表格
    layui.use('table', function(){
        var table = layui.table;
        var id=<?=$id?>;
        var url="<?=base_url("word/words/get_table")?>";
        var html=url+"?type_id="+id;
        //第一个实例
        var tableIns = table.render({
            elem: '#demo'
            ,height: 500
//                ,url: "<?//=base_url("word/words/get_table")?>//" //数据接口
            ,url: html //数据接口
            ,page: true //开启分页
            ,cols: [[ //表头
                {field: 'input', title: '', width:50}
                ,{field: 'quality_uuid', title: '视频id', width:100}
                ,{field: 'img', title: '缩略图', width:80}
                ,{field: 'quality_desc', title: '简介', width:200}
                ,{field: 'quality_join_type_sub_name', title: '话题', width:150}
                ,{field: 'add_time', title: '添加时间', width: 120, sort: true}
            ]]
        });

    });

</script>